// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 首页
import index from '@/views/index';


// 启用路由
Vue.use(Router);
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

// 导出路由 
export default new Router({
    routes: [
        {
            path: '/error',
            name: '页面错误',
            component: () => import('@/components/error'),
            hidden: true,
            meta: {
                requireAuth: false
            }
        },
        {
            path: '/index',
            name: '首页',
            component: index,
            iconCls: 'el-icon-tickets',
            children: [{ // 工作台-统计
                path: '/statistics',
                name: 'Statistics',
                component: () => import('@/views/workbench/statistics'),
                meta: {
                    requireAuth: true,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                    breadNumber: 1,
                    meta: {
                        requireAuth: true,
                        title: "",
                        visiable: true,
                        roles: ['admin'],
                    }
                }
            }, {
                path: 'addEnterprise',
                name: 'AddEnterprise',
                component: () => import('@/views/pageWorld/addEnterprise'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                path: 'addCustomerData',
                name: 'AddCustomerData',
                component: () => import('@/views/pageWorld/addCustomerData'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                path: 'addFollowUp',
                name: 'AddFollowUp',
                component: () => import('@/views/pageWorld/addFollowUp'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, { // 客户
                path: '/customer',
                name: 'Customer',
                component: () => import('@/views/customer/hinge'),
                children: [
                    {
                        path: 'cAnalysis',
                        name: 'CAnalysis',
                        component: () => import('@/views/customer/cAnalysis'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'contactsList',
                        name: 'ContactsList',
                        component: () => import('@/views/customer/customer'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'enterprise',
                        name: 'Enterprise',
                        component: () => import('@/views/customer/enterprise'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'customerBase',
                        name: 'CustomerBase',
                        component: () => import('@/views/customer/customerBase'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'recycleBin',
                        name: 'RecycleBin',
                        component: () => import('@/views/customer/recycleBin'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'highSeas',
                        name: 'HighSeas',
                        component: () => import('@/views/customer/highSeas'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'customerSetup',
                        name: 'CustomerSetup',
                        component: () => import('@/views/customer/customerSetup'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'externalContacts',
                        name: 'ExternalContacts',
                        component: () => import('@/views/customer/externalContacts'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    }
                ]
            }, { // 销售
                path: '/sale',
                name: 'Sale',
                component: () => import('@/views/sale/hinge'),
                children: [
                    {
                        path: 'target',
                        name: 'Target',
                        component: () => import('@/views/sale/target'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'opportunity',
                        name: 'Opportunity',
                        component: () => import('@/views/sale/opportunity'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'salesSettings',
                        name: 'SalesSettings',
                        component: () => import('@/views/sale/salesSettings'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                    {
                        path: 'workRecord',
                        name: 'WorkRecord',
                        component: () => import('@/views/sale/workRecord'),
                        meta: {
                            requireAuth: true,
                            breadNumber: 1,
                            visiable: true,
                            roles: ['admin'],
                            platform: "front,Administration",
                        }
                    },
                ]
            }, {
                // 组织架构
                path: '/framework/framework',
                name: 'Framework',
                component: () => import('@/views/framework/framework'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 角色权限
                path: '/jurisdiction/jurisdiction',
                name: 'Jurisdiction',
                component: () => import('@/views/jurisdiction/jurisdiction'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 标签库
                path: '/labelLibrary/labelLibrary',
                name: 'LabelLibrary',
                component: () => import('@/views/labelLibrary/labelLibrary'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 企业等级
                path: '/enterpriseLevel/enterpriseLevel',
                name: 'EnterpriseLevel',
                component: () => import('@/views/enterpriseLevel/enterpriseLevel'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 客户来源
                path: '/customerSource/customerSourceList',
                name: 'CustomerSourceList',
                component: () => import('@/views/customerSource/customerSourceList'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 跟进状态
                path: '/followUp/followUpList',
                name: 'FollowUpList',
                component: () => import('@/views/followUp/followUpList'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            }, {
                // 销售阶段
                path: '/salesStage/salesStageList',
                name: 'SalesStageList',
                component: () => import('@/views/salesStage/salesStageList'),
                meta: {
                    requireAuth: true,
                    breadNumber: 1,
                    visiable: true,
                    roles: ['admin'],
                    platform: "front,Administration",
                }
            },
            ]
        }]
})